package com.itheima.example;

import java.io.*;

public class Example05 {
    public static void main(String[] args) throws Exception {
        // 创建一个带缓冲区的输入流
        BufferedInputStream bufferInput = new BufferedInputStream(new FileInputStream("source\\IMG_7799.jpg"));
        // 创建一个带缓冲区的输出流
        BufferedOutputStream bufferOutput = new BufferedOutputStream(new FileOutputStream("target\\IMG_7799.jpg"));
        long startTime = System.currentTimeMillis();
        int length;
        while ((length = bufferInput.read()) != -1) {
            bufferOutput.write(length);
        }
        long endTime = System.currentTimeMillis();
        System.out.println("复制图片所消耗的时间是:" + (endTime - startTime) + "毫秒");
        bufferInput.close();
        bufferOutput.close();
    }
}
